<template>
    <el-menu default-active="1" router>
        <el-menu-item index="/adminInfo">
            <span>基本信息</span>
        </el-menu-item>
        <!-- 管理员 -->
        <el-sub-menu index="1"
            v-if="role == 2 && (permission.resident == 1 || permission.doctor == 1 || permission.admin == 1)">
            <template #title>
                <span>用户管理</span>
            </template>
            <el-menu-item index="/resident" v-if="permission.resident == 1">
                <span>居民账号</span>
            </el-menu-item>
            <el-menu-item index="/doctor" v-if="permission.doctor == 1">
                <span>医生账号</span>
            </el-menu-item>
            <el-menu-item index="/admin" v-if="permission.admin == 1">
                <span>管理员账号</span>
            </el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="2"
            v-if="role == 2 && (permission.institution == 1 || permission.medication_device == 1 || permission.type_info == 1)">
            <template #title>
                <span>医疗资源管理</span>
            </template>
            <el-menu-item index="/healthInstitution" v-if="permission.institution == 1">
                <span>医疗机构管理</span>
            </el-menu-item>
            <el-menu-item index="/medicalDevice" v-if="permission.medication_device == 1">
                <span>医疗器械管理</span>
            </el-menu-item>
            <el-menu-item index="/medication" v-if="permission.medication_device == 1">
                <span>药品管理</span>
            </el-menu-item>
            <el-menu-item index="/department" v-if="permission.type_info == 1">
                <span>科室管理</span>
            </el-menu-item>
            <el-menu-item index="/title" v-if="permission.type_info == 1">
                <span>职称管理</span>
            </el-menu-item>
            <el-menu-item index="/institutionType" v-if="permission.type_info == 1">
                <span>医疗机构类型管理</span>
            </el-menu-item>
        </el-sub-menu>
        <el-menu-item index="/appointment" v-if="role == 2 && permission.appointment_admin == 1">
            <span>预约挂号管理</span>
        </el-menu-item>
        <el-menu-item index="/roleManage" v-if="role == 2 && permission.role_manage == 1">
            <span>角色与权限管理</span>
        </el-menu-item>
        <!-- 医生 -->
        <el-menu-item index="/appointmentDoctor" v-if="role == 1 && permission.appointment_doctor == 1">
            <span>预约挂号</span>
        </el-menu-item>
        <el-menu-item index="/evaluate" v-if="role == 1 && permission.evaluation == 1">
            <span>患者评价</span>
        </el-menu-item>
        <!-- 系统管理 -->
        <el-sub-menu index="3" v-if="role == 2 && (permission.announcement == 1 || permission.opinion == 1)">
            <template #title>
                <span>系统管理</span>
            </template>
            <el-menu-item index="/announcement" v-if="permission.announcement == 1">
                <span>公告管理</span>
            </el-menu-item>
            <el-menu-item index="/opinion" v-if="permission.opinion == 1">
                <span>意见反馈</span>
            </el-menu-item>
        </el-sub-menu>
    </el-menu>
</template>

<script>
export default {
    data() {
        return {
            role: '',
            permission: {}
        }
    },
    created() {
        if (JSON.parse(sessionStorage.getItem("user"))) {
            this.role = JSON.parse(sessionStorage.getItem("user")).role;
        }
        if (JSON.parse(sessionStorage.getItem("permission"))) {
            this.permission = JSON.parse(sessionStorage.getItem("permission"));
        }
    }
}
</script>

<style scoped>
.el-menu {
    height: 100%;
}
</style>